<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>箭头函数</title>
</head>

<body>
  <script>
    const fn1 = () => {
      console.log(1);
    }
    fn1()

    // const fn2 = (x) => {
    //   console.log(x);
    // }

    // 只有一个形参的时候,可以省略小括号
    const fn2 = x => {
      console.log(x);
    }
    fn2(2)

    // const fn3 = (x) => {
    //   console.log(3);
    // }
    // 只有一行代码时,可以省略大括号
    const fn3 = x => console.log(3);
    fn3()

    // const fn4 = x => {
    //   return x + x
    // }

    // return只有一行代码时,可以省略return
    const fn4 = x => x + x
    console.log(fn4(4));
  </script>
</body>

</html>